/**
 * Licensee: Universidad de Almeria
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListAgendaRMI2Data {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		System.out.println("Listing Registro...");
		orm.Registro[] ormRegistros = orm.RegistroDAO.listRegistroByQuery(null, null);
		int length = Math.min(ormRegistros.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormRegistros[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Registro by Criteria...");
		orm.RegistroCriteria registroCriteria = new orm.RegistroCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//registroCriteria.telefono.eq();
		registroCriteria.setMaxResults(ROW_COUNT);
		orm.Registro[] ormRegistros = registroCriteria.listRegistro();
		int length =ormRegistros== null ? 0 : Math.min(ormRegistros.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormRegistros[i]);
		}
		System.out.println(length + " Registro record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListAgendaRMI2Data listAgendaRMI2Data = new ListAgendaRMI2Data();
			try {
				listAgendaRMI2Data.listTestData();
				//listAgendaRMI2Data.listByCriteria();
			}
			finally {
				orm.AgendaRMI2PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
